#    One Room And A Goblin Invasion
#    Copyright (C) 2014  Jannik Haberbosch
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.

import pygame
pygame.init

from code.Text import Text
from code import game_constants


class Button( pygame.sprite.Sprite ):
	def __init__( self,
		text,
		lefttop_position = ( 0, 0 ),
		color = game_constants.BLACK,
		fontsize = 12,
		color_active = game_constants.WHITE ):
		"""

		"""
		pygame.sprite.Sprite.__init__( self )

		self.color_active = color_active


		self.text_inactive = Text(
			text,
			lefttop_position,
			color,
			fontsize
		)
		self.text_active = Text(
			text,
			lefttop_position,
			self.color_active,
			fontsize
		)
		
		self.image = self.text_inactive.image
		self.rect = self.text_inactive.rect


	def update( self ):
		"""

		"""
		if self.rect.collidepoint( pygame.mouse.get_pos() ):
			self.image = self.text_active.image
			self.rect = self.text_active.rect
			if pygame.mouse.get_pressed()[0]:
				return True
		else:
			self.image = self.text_inactive.image
			self.rect = self.text_inactive.rect
